{% extends "base.volt" %}
{% block pageHeader %}
	{{ stylesheet_link("/assets/manage/css/tabstyle.css", false) }}
	{{ stylesheet_link("/libs/bootstrap-daterangepicker/daterangepicker.css", false) }}
{% endblock %}
{% block pageFooter%}
    {{ javascript_include("/libs/bootstrap-daterangepicker/moment.min.js", false) }}
    {{ javascript_include("/libs/bootstrap-daterangepicker/daterangepicker.js", false) }}
    {{ javascript_include("/assets/manage/js/question/list.js", false) }}
{% endblock %}

{% block content %}
    {{ partial("module/left_question") }}
    <div class="col-xs-10">
        <ol class="breadcrumb">
            <li><a href="{{ url.get('question/list') }}">问答</a></li>
            <li><a href="{{ url.get('question/list') }}">问答管理</a></li>
            <li class="active">问答列表</li>
        </ol>
        {% if cityCode != -1 %}
		<div class="commtable">
	    	<ul>	
	    		<li {% if filterState == -10000 and filterNew == -1 %} class="hover" {% endif %}><a href="{{ url.get('question/list') }}">全部</a></li>
	    		<li {% if filterState == 1 %} class="hover" {% endif %}><a href="{{ url.get('question/list?filterState=1') }}" >正常</a></li>
	    		<li {% if filterNew == 0 %} class="hover" {% endif %}><a href="{{ url.get('question/list?new=0') }}" >最新问答</a></li>
	    		<li {% if filterState == -1 %} class="hover" {% endif %}><a href="{{ url.get('question/list?filterState=-1') }}">已删除</a></li>
	    		
	    	</ul>
    	</div>
    {% endif %}
    <div style="clear:both;"></div>
        <div class="panel panel-default">
            <div class="panel-body">
                <form class="form-inline" role="form" action="" method="get">
                    <!-- <div class="form-group">
                        <div class="input-group">
                            <label class="input-group-addon" for="filterTag">分类:</label>
                            <select class="form-control" name="filterTag" id="filterTag">\
                                <option value="-10000" {{ filterTag == -10000 ? 'selected="selected"' : '' }} >全部</option>
                                {% for t in tagList  %}
                                <option value="{{ t.tag_id }}" {{ filterTag == t.tag_id ? 'selected="selected"' : '' }} >{{ t.tag_title }}</option>
                                {%  endfor %}
                            </select>
                        </div>
                    </div> -->
                    <!-- <div class="form-group">
                        <div class="input-group">
                            <label class="input-group-addon" for="filterState">状态:</label>
                            <select class="form-control" name="filterState" id="filterState">
                                <option value="-10000" {{ filterState == -10000 ? 'selected="selected"' : '' }} >全部</option>
                                <option value="1" {{ filterState == 1 ? 'selected="selected"' : '' }} >正常</option>
                                <option value="-1" {{ filterState == -1 ? 'selected="selected"' : '' }} >删除</option>
                            </select>
                        </div>
                    </div> -->
                    <div class="form-group">
                        <div class="input-group">
                            <label class="input-group-addon">城市</label>
                            <select name="city_id" class="form-control">
                                <option value="0">未选择</option>
                                {% for r in openCity %}
                                <option value="{{ r.city_code }}" {% if city_id ==  r.city_code%} selected {% endif %}>{{ r.city_name }}</option>
                                {% endfor %}
                            </select>
                        </div>

                    </div>
                    <div class="form-group">
                    <input type="hidden" name="filterState" value="{{ filterState }}" />
                        <div class="input-group">
                            <label class="input-group-addon" for="filterUser">用户名:</label>
                            <input class="form-control" type="text" name="filterUser" id="filterUser" value="{{ filterUser ? filterUser : '' }}" />
                            <input type="hidden" name="cityCode" value="{{cityCode}}">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <label class="input-group-addon" for="filterUser">内容:</label>
                            <input class="form-control" type="text" name="qcontent" id="qcontent" value="{{ qcontent }}" />
                        </div>  
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <label class="input-group-addon" for="filterUser">标签:</label>
                            <input class="form-control" type="text" name="qtag" id="qtag" value="{{ filtertag }}" />
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <label class="input-group-addon" for="filterUser">提问时间:</label>
                            <input class="form-control" type="text" name="inputtime" style="width:300px;" id="activity_time" value="{{ inputtime }}" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary"><i class="fa fa-filter"></i> 搜 索</button>
                    </div>
                </form>
            </div>
        </div>

        <table class="table table-hover">
            <thead>
            <tr>
                <th style="width: 60px;">ID</th>
                <th style="width: 100px;">用户</th>
                <th style="width: 60px;">标签</th>
                <th>内容</th>
                <th style="width: 80px;">城市</th>
                <th style="width: 80px;">回答</th>
                <th style="width: 60px;">状态</th>
                <th style="width: 150px;">提问时间</th>
                <th style="width: 120px;"></th>
            </tr>
            </thead>
            {% for d in data %}
                <tr>
                    <td>{{ d['question_id'] }}</td>
                    <td>{{ d['user_nickname']|e }}</td>
                    <td>{% for r in d['question_tag'] %} {{ r }}<br/> {% endfor %}</td>
                    <td>{{ d['question_content']|e }}
                        <div class="question_photos_box">
                        {% for pic in json_decode(d['question_pics']) %}
                            <div class="pic_list">
                                <a href="{{ PicUrlQuestion(pic, this.getDi()) }}" class="thumbnail" target="_blank">
                                    <img src="{{ PicUrlQuestion(pic, this.getDi()) }}@!120" alt="" />
                                </a>
                            </div>
                        {% endfor %}
                        </div>
                    </td>
                    <td>
                    	{% for r in openCity %}
                    		{% if r.city_code == d['city_code'] %}
                    			{{ r.city_name }}
                    		{% endif %}
                    	{% endfor %}
                    </td>
                    <td>{{ d['answer_num'] }}</td>
                    <td>
                    {% if d['question_state'] == -1 %} 删除 {% endif %}
                    {% if d['question_state'] == 1 %} 正常 {% endif %}
                    {% if d['question_state'] == 2 %} 精华 {% endif %}
                    </td>
                    <td>{{ d['question_addtime'] }}</td>
                    <td>
                        <div class="dropdown">
                            <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu{{ d['question_id'] }}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"><i class="fa fa-cogs"></i> 操作 <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="dropdownMenu{{ d['question_id'] }}">
                                {% if d['question_state'] == 1 %}
                                <li><a href="/frontend/share/questionPreview?id={{ d['question_id'] }}" target="_blank"><i class="fa fa-eye fa-fw"></i> 预览</a></li>
                                {% endif %}
                                {% if d['question_state'] == 1 %}
                                <li><a href="/manage/questionmanage/info?id={{ d['question_id'] }}" target="_blank"><i class="fa fa-eye fa-fw"></i> 查看</a></li>
                                {% endif %}
                                <!-- <li><a class="but_answer_list" durl="{{ url.get('question/answerList', ['id': d['question_id']]) }}" href="javascript:void(0)"><i class="fa fa-info fa-fw"></i> 回答管理</a></li> -->
                                 {% if d['question_state'] == 1 %}
                                <li><a href="{{ url.get('question/question_recommend_add',['id' : d['question_id']]) }}" ><i class="fa fa-pencil fa-fw"></i> 推荐到首页</a></li>
                                {% endif %}
                                <li><a href="{{ url.get('question/edit',['id' : d['question_id']]) }}" ><i class="fa fa-pencil fa-fw"></i> 编辑</a></li>
                                <li role="separator" class="divider"></li>
                                {% if d['question_state'] == 1 %}
                                    <li><a href="javascript:void(0)" durl="{{ url.get('question/setState') }}" did="{{ d['question_id'] }}" dstate="-1" class="but_set_state"><i class="fa fa-trash-o fa-fw"></i> 删 除</a></li>
                                {% endif %}
                                {% if d['question_state'] == -1 %}
                                    <li><a href="javascript:void(0)" durl="{{ url.get('question/setState') }}" did="{{ d['question_id'] }}" dstate="1" class="but_set_state"><i class="fa fa-reply fa-fw"></i> 恢 复</a></li>
                                {% endif %}
                            </ul>
                        </div>
                    </td>
                </tr>
            {% endfor %}
        </table>

        {{ this.tagNav.page(
        page,
        total,
        limit,
        url.get('question/list', [
            'qcontent': qcontent,
            'filterState': filterState,
            'filterUser': filterUser,
            'qcontent' : qcontent,
            'qtag' : filtertag,
            'city_id' : city_id,
            'inputtime' : inputtime,
            'cityCode' : cityCode,
            'page': '__PAGE__'
        ]
        )) }}
    </div>
{% endblock %}